package com.sishu.njrtsdms.controller;

import cn.hutool.core.lang.tree.Tree;
import com.sishu.njrtsdms.domain.core.R;
import com.sishu.njrtsdms.domain.dto.DictDataForTreeDTO;
import com.sishu.njrtsdms.domain.dto.DictDataNormalDTO;
import com.sishu.njrtsdms.domain.dto.DictTypeForTreeDTO;
import com.sishu.njrtsdms.domain.dto.DictTypeNormalDTO;
import com.sishu.njrtsdms.domain.vo.DictDataVO;
import com.sishu.njrtsdms.domain.vo.DictTypeVO;
import com.sishu.njrtsdms.service.DictDataService;
import lombok.extern.slf4j.Slf4j;
import org.jooq.types.ULong;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 字典相关控制器
 */
@RestController
@RequestMapping("/dict")
@Slf4j
public class DictController {

    private final DictDataService dictDataService;


    public DictController(DictDataService dictDataService) {
        this.dictDataService = dictDataService;
    }

    @GetMapping("/listDictType")
    public R<List<DictTypeVO>> listDictType(DictTypeNormalDTO dictTypeNormalDTO) {
        List<DictTypeVO> dictTypeVOList = dictDataService.listDictType(dictTypeNormalDTO);
        return R.ok(dictTypeVOList);
    }

    @GetMapping("/listDictTypeForTree")
    public R<List<Tree<ULong>>> listDictTypeForTree(DictTypeForTreeDTO dictTypeDTO) {
        List<Tree<ULong>> dictTypeVOForTreeList = dictDataService.listDictTypeForTree(dictTypeDTO);
        return R.ok(dictTypeVOForTreeList);
    }

    @GetMapping("/listDictData")
    public R<List<DictDataVO>> listDictData(DictDataNormalDTO dictDataNormalDTO) {
        List<DictDataVO> dictDataVOList = dictDataService.listDictData(dictDataNormalDTO);
        return R.ok(dictDataVOList);
    }

    @GetMapping("/listDictDataForTree")
    public R<List<Tree<ULong>>> listDictDataForTree(DictDataForTreeDTO dictDataForTreeDTO) {
        List<Tree<ULong>> dictDataVOForTreeList = dictDataService.listDictDataForTree(dictDataForTreeDTO);
        return R.ok(dictDataVOForTreeList);
    }


}
